﻿@using ERP.WebUI;
@model SearchModel
@{
    ViewBag.Title = ViewBag.CurrentTitle;
    var deleteAllButton = new ButtonModel();
    deleteAllButton = ViewBag.DeleteAll;
}
@section css{
    @Styles.Render("~/bundles/css/jqueryui")
}

<div id="content-body" class="row-fluid">
    <div class="span22">
        <!--操作 -->
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon"><i class="icon-search"></i></span>
                <h5>操作</h5>
            </div>
            <div class="widget-content nopadding">
                <form class="form-horizontal search-form" method="post" name="basic_validate" novalidate="novalidate">
                    <div class="control-group">
                        <div class="search-group">
                            <label class="search-label">@Html.DisplayNameFor(t => t.Area)</label>
                            <div class="span2 search-input">
                                @Html.TextBoxFor(t => t.Area)
                            </div>
                        </div>
                        <div class="search-group">
                            <label class="search-label">@Html.DisplayNameFor(t => t.Controller)</label>
                            <div class="span2 search-input">
                                @Html.TextBoxFor(t => t.Controller)
                            </div>
                        </div>
                        <div class="search-group">
                            <label class="search-label">@Html.DisplayNameFor(t => t.Action)</label>
                            <div class="span2 search-input">
                                @Html.TextBoxFor(t => t.Action)
                            </div>
                        </div>
                    </div>

                    <div class="control-group">
                        <div class="search-group">
                            <label class="search-label">@Html.DisplayNameFor(t => t.LoginName)</label>
                            <div class="span2 search-input">
                                @Html.TextBoxFor(t => t.LoginName)
                            </div>
                        </div>
                        <div class="search-group">
                            <label class="search-label">@Html.DisplayNameFor(t => t.IPAddress)</label>
                            <div class="span2 search-input">
                                @Html.TextBoxFor(t => t.IPAddress)
                            </div>
                        </div>
                    </div>

                    <div class="control-group">
                        <div class="search-group">
                            <label class="search-label">@Html.DisplayNameFor(t => t.StartTime)</label>
                            <div class="span2 search-input">
                                @Html.DatePickerFor(t => t.StartTime)
                            </div>
                        </div>
                        <div class="search-group">
                            <label class="search-label">@Html.DisplayNameFor(t => t.EndTime)</label>
                            <div class="span2 search-input">
                                @Html.DatePickerFor(t => t.EndTime)
                            </div>
                        </div>
                    </div>

                    <div class="form-actions form-operate text-right" style="border-top: 0;">
                        <button type="button" class="btn btn-danger" onclick="ClearForm($('.search-form'));">
                            <span class="icon-bullhorn"></span>清空
                        </button>
                        <button type="button" class="btn btn-success" onclick="Search()">
                            <span class="icon-search"></span>搜索
                        </button>
                        @if (deleteAllButton != null)
                        {
                            <button type="button" class="create btn btn-primary" onclick="DeleteAll()">
                                <span class="@deleteAllButton.Icon"></span>@deleteAllButton.Text
                            </button>
                        }
                    </div>
                </form>
            </div>
        </div>

        <!--列表-->
        <div class="widget-box">
            <div class="widget-title">
                <span class="icon"><i class="icon-th"></i></span>
                <h5>操作日志列表</h5>
            </div>
            <div class="widget-content nopadding">
                <table class="table table-bordered data-table">
                    <thead>
                        <tr>
                            <th width="5%">序号</th>
                            <th width="15%">操作时间</th>
                            <th width="12%">区域</th>
                            <th width="12%">控制器</th>
                            <th width="12%">动作</th>
                            <th width="15%">操作描述</th>
                            <th width="15%">IP地址</th>
                            <th width="12%">操作用户</th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
        </div>

    </div>
</div>

@section scripts{
    @Scripts.Render("~/bundles/jqueryui")
    <script type="text/javascript">
        var oTable = null;

        $(function () {
            var actionUrl = "@Url.Action("List")?rand=" + Math.random();
            var aoColumns = [
                    { "sName": "SortId", "bSortable": false },
                    { "sName": "LogTime", "bSortable": false },
                    { "sName": "Area", "bSortable": false },
                    { "sName": "Controller", "bSortable": false },
                    { "sName": "Action", "bSortable": false },
                    { "sName": "Description", "bSortable": false },
                    { "sName": "IPAddress", "bSortable": false },
                    { "sName": "LoginName", "bSortable": false }
            ];
            //初始化表格
            oTable = InitDatatables($(".data-table"), actionUrl, aoColumns, oTable);
        });

        //查询
        function Search() {
            var filterdata = $(".search-form").serialize();
            oTable.fnReloadAjax("@Url.Action("List")?rand=" + Math.random() + "&" + filterdata);
        }

        //删除
        function DeleteAll() {
            var actionUrl = "@Url.Action("DeleteAll")";
            DeleteAllRecord(actionUrl, oTable);
        }

    </script>
}